/**
 * @fileoverview Scripts for mm2notes-gae
 * @author scottakirkwood@gmail.com (Scott Kirkwood)
 */

google.load('dojo', '1.3.2');

function init() {
    var adate = dojo.byId('date');
    if (!adate.value) {
        var today = new Date();
        mo = '' + (today.getMonth() + 1);
        if (mo.length == 1) {
            mo = '0' + mo;
        }
        dt = '' + today.getDate();
        if (dt.length == 1) {
            dt = '0' + dt;
        }
        var str = today.getFullYear() + '-' + mo + '-' + dt;
        adate.value = str;
    }
}

function delete_post(key) {
    dojo.xhrPost({ 
        url: '/delete',
        handleAs: 'text',
        preventCache: true,               
        content: { 'key': key },
        load: function(response, args) {
            dojo.query('#message').innerHTML = 'Deleted';
            window.location = '/';
        },
        error: function(response, args) {
            dojo.query('#message').innerHTML = 'Error';
        },
    });
}
